package com.servlet.test; /**
 * @author : DuJiabao
 * @Date : 2021/1/24 17:50
 * @Project : java-web
 * @File : ${FILE_NAME}
 * @Desc : 请求转发测试
 */

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

// 通过注解的方法，就不需要在xml文件上写了
// name 就是xml上面的 servlet-name，value就是url-pattern
@WebServlet(name = "RequestDispatcherTest2", value = "/RequestDispatcherTest2")
public class RequestDispatcherTest2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        获取请求参数
        String username = request.getParameter("username");
        System.out.println(username);
//        获取通过context传递的参数
        System.out.println(request.getAttribute("key"));
//        处理自己的任务
        System.out.println("RequestDispatcherTest2 处理");
    }
}
